package design.mode.effective_java.chapter7.item43;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ZhongMingde on 2021/8/28
 */

public class Main {

    public static void main(String[] args) {
        Map<Integer, Integer> map = new HashMap();
        map.merge(2, 1, (count, incr) -> count + incr);
        map.forEach((key, value) -> {
            System.out.println(key + ":" + value);
        });
        map.merge(2, 3, Integer::sum);
        map.forEach((key, value) -> {
            System.out.println(key + ":" + value);
        });
    }
}
